#include"reg52.h"
#include "speaker.h"
#include "lcd1602.h"
#include<intrins.h>
#include <math.h>

uint peopleNums=0;
uchar table[] ="0123456789";
uchar table1[] ="Infrared Alarm";
uchar table2[] ="People:";
uchar bai,shi,ge;

void math(uint x) 
{
    bai = x / 100; 
    shi = x /10 % 10;
    ge = x % 10;
}

void refrash(){
		    write_com(0x80);
            print_data(table1);
            write_com(0x80+0x40);
            print_data(table2);
			math(peopleNums);
			write_data(table[bai]);
            write_data(table[shi]);
            write_data(table[ge]);  
}

void main()
{     cs=0;
	  speaker = 0;
	  havePeople = 0;
      init(); 
	  refrash();
      while(1)
        {   
           if(havePeople==1&&alarmButton==1){
              speaker = 1;
			  peopleNums++;
			  refrash();
			  delayms(3000);
			  speaker = 0;
         }
        }

}